package com.cqjtu.education.service.impl;

import com.cqjtu.education.entity.Section;
import com.cqjtu.education.dao.SectionDao;
import com.cqjtu.education.service.SectionService;
import com.github.pagehelper.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (Section)表服务实现类
 *
 * @author makejava
 * @since 2022-04-20 15:49:08
 */
@Service("sectionService")
public class SectionServiceImpl implements SectionService {
    @Resource
    private SectionDao sectionDao;

    /**
     * 通过ID查询单条数据
     *
     * @param sectionId 主键
     * @return 实例对象
     */
    @Override
    public Section queryById(String sectionId) {
        return this.sectionDao.queryById(sectionId);
    }


    /**
     * 新增数据
     *
     * @param section 实例对象
     * @return 实例对象
     */
    @Override
    public Section insert(Section section) {
        this.sectionDao.insert(section);
        return section;
    }

    /**
     * 修改数据
     *
     * @param section 实例对象
     * @return 实例对象
     */
    @Override
    public Section update(Section section) {
        this.sectionDao.update(section);
        return this.queryById(section.getSectionId());
    }

    /**
     * 通过主键删除数据
     *
     * @param sectionId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String sectionId) {
        return this.sectionDao.deleteById(sectionId) > 0;
    }
}
